package com.szamc.tableroundapi.model.RecursionTable;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class TreeItem {
    private String id;
    private int index;
    private int groupLevel;
    private List<Integer> groupIndexPathList;
    private int value;


    public TreeItem(String id, int groupLevel, List<Integer> groupIndexPathList,int index, int value) {
        List<Integer> _groupIndexPathList = new ArrayList<>(groupIndexPathList);
        _groupIndexPathList.remove(groupIndexPathList.size() - 1);
        this.id = id;
        this.groupLevel = groupLevel;
        this.groupIndexPathList = _groupIndexPathList;
        this.index = index;
        if(_groupIndexPathList.size()>=2){
            List<Integer> copiedPathList = new ArrayList<>(_groupIndexPathList);
            copiedPathList.remove(copiedPathList.size() - 1);
        }
        this.value = value;
    }
}
